package com.offdissys.common.utils.token;

import cn.hutool.extra.spring.SpringUtil;
import com.offdissys.common.redis.service.CacheService;
import com.offdissys.common.redis.service.RedisService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

/**
 * @author ZhangHaiWen
 * @title: DefaultConfig
 * @projectName parent
 * @description: 配置类
 * @date 2022/3/715:49
 */
@Component(value = "defaultConfig")
@PropertySource("classpath:utils.properties")
public class DefaultConfig implements TokenConfig{

    @Value("${token.secretCode:20220307SecretCode}")
    private String secretCode;

    @Value("${token.offsetDay:15}")
    private Integer offsetDay;

    @Value("${token.cacheHead:TOKEN_HEAD}")
    private String cacheHead;

    @Override
    public String cacheHead() {
        return cacheHead;
    }

    @Override
    public String secretCode() {
        return secretCode;
    }

    @Override
    public Integer offsetDay() {
        return offsetDay;
    }

    @Override
    public CacheService cacheService() {
        return SpringUtil.getBean(RedisService.class);
    }

}
